<%@ page import="cn.edu.zut.model.Book" %>
<%@ page import="java.util.List" %>
<%@ page import="cn.edu.zut.dto.BookAndType" %><%--
  Created by IntelliJ IDEA.
  User: 徐维维
  Date: 2019/6/24
  Time: 11:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <title>图书检索</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/js/bootstrap.min.css">
    <script src="/js/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/bootstrap-table.min.js"></script>
    <script src="/js/bookstrapreader.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/userbook.css"/>
    <style>
        #s1{
            text-align: center;
        }
        th{
            text-align: center;
        }
        td{
            text-align: center;
        }
    </style>
    <script>
        $(document).ready(function(){
            $("#table_page").bootstrapTable({
                columns:[{
                    field:'id',
                    title:'Id'
                },{
                    field:'ISBN',
                    title:'isdn'
                },{
                    field:'BookName',
                    title:'图书名称'
                },{
                    field:'Author',
                    title:'作者'
                },{
                    field:'Type',
                    title:'类别'
                },{
                    field:'Publish',
                    title:'出版社'
                },{
                    field:'UnitPrice',
                    title:'单价'
                },{
                    field:'Status',
                    title:'状态'
                },{
                    field:'Operation',
                    title:'操作'
                },],
                formatLoadingMessage:function () {
                    return "";
                },
            });
        });
    </script>
</head>
<body>
<h2 align="center">图书检索</h2>

    <form action="/checkBook" id="s1">
        <select id="select" name="selectName">
            <option value="书名">书名</option>
            <option value="isbn">isbn</option>
            <option value="作者">作者</option>
            <option value="类别">类别</option>
            <option value="出版社">出版社</option>
        </select>
        <input class ="put1" type="text" name="search" placeholder="请输入关键字">
        <input class ="put2" type="submit" value="搜索">
    </form>


<div >
        <table class="table table-striped  table-bordered table-condensed" id="table_page"
               data-pagination="true"
               data-side-pagination="client"
               data-page-size="6">
                <%
                String str1="<a href = \"javascript:void(0)\" onclick = \"document.getElementById('";
                String str2="').style.display='block'\">";//定义按钮触发事件
                List<BookAndType> books= (List<BookAndType>)session.getAttribute("bookALL");

                for (BookAndType book: books){
                    out.println("<tr>");
                    out.println("<td>"+book.getBookid()+"</td>");
                    out.println("<td>"+book.getIsbn()+"</td>");
                    out.println("<td>"+book.getBookname()+"</td>");
                    out.println("<td>"+book.getAuthor()+"</td>");
                    out.println("<td>"+book.getTypename()+"</td>");
                    out.println("<td>"+book.getPublish()+"</td>");
                    out.println("<td>"+book.getUnitprice()+"</td>");
                    if(book.getStatus()==0)
                        out.println("<td>"+"在馆" +"</td>");
                    else
                        out.println("<td>"+"借出" +"</td>");
                    String str=str1+book.getBookid()+str2;
                    out.println("<td><button type=\"button\" class=\"btn btn-success btn-xs\">"+str+"详情</a></button></td>");
                    System.out.println(str);
                    pageContext.setAttribute("everyBookId",book.getBookid());
            %>
            <div id=${everyBookId} class="cont">
                <p style="text-align: right"><a href = "javascript:void(0)"
                                                onclick = "document.getElementById(${everyBookId}).style.display='none'">关闭</a></p>
                <div id = "s11">
                    <h3>书籍信息</h3>
                </div>
                <div>
                    <img src="/image/book.png"></img>
                </div>
                <div id="aa1">
                    <%
                        out.println("<p>书本ID:"+book.getBookid()+"</p>");
                        out.println("<p>书本ISBN:"+book.getIsbn()+"</p>");
                        out.println("<p>书本名:"+book.getBookname()+"</p>");
                        out.println("<p>书本作者:"+book.getAuthor()+"</p>");
                        out.println("<p>书本出版社:"+book.getIsbn()+"</p>");
                        out.println("<p>书本出版日期:"+book.getPublishdate()+"</p>");
                        out.println("<p>书本发行次数:"+book.getPublishtime()+"</p>");
                        out.println("<p>书本价格:"+book.getUnitprice()+"</p>");
                    %>
                </div>
            </div>
                        <%
                    out.println("</tr>");
                }
            %>
    </table>
</div>

</body>
</html>